
#include "Miro.h"
#include "Scene.h"
#include "Camera.h"
#include "Image.h"
#include "Console.h"

#include "PointLight.h"
#include "Sphere.h"
#include "AARect.h"

#include "Lambert.h"
#include "Shiny.h"
#include "SeeThru.h"
#include "OptimusMaterius.h"

#include "MiroWindow.h"
#include "LuminusMaterius.h"


void make272Scene()
{
    g_camera = new Camera;
    g_scene = new Scene;
	g_hdrImage = new HdrImage;
	g_image = g_hdrImage->getLdrImage();

	//g_hdrImage->resize(100,100);
	g_hdrImage->resize(512, 512);

    // set up the camera
    g_camera->setBGColor(Vector3(0.0f, 0.0f, 0.0f));
	g_camera->setEye(Vector3(0, 0, -2));
    g_camera->setLookAt(Vector3(0, 0, 0));
    g_camera->setUp(Vector3(0, 1, 0));
    g_camera->setFOV(90);

    PointLight *plight = new PointLight;
    plight->setPosition(Vector3(0,2,0));
    plight->setColor(Vector3(1,1,1));
    plight->setWattage(100);
    //g_scene->addLight(plight);

    RectLight *r_light = new RectLight();
    r_light->setAARect(Vector3(-10,2,-1),Vector3(10,2,1), YAXIS, Vector3(0,-1,0));
	r_light->setColor(Vector3(1,1,1));
	r_light->setWattage(1000);
	g_scene->addAreaLight(r_light);
	g_scene->addObject(r_light);

	// set the environment map
	EnvMap *pEnvMap = new EnvMap();
	pEnvMap->setRgb(Vector3(0));
	g_scene->setEnvMap(pEnvMap);


	Material *lambert = new Lambert(Vector3(0.75));
	Material *shiny = new Shiny(Vector3(0.75));
	Material *seethru = new OptimusMaterius(Vector3(0), Vector3(0.75));

	Sphere *sphere = new Sphere();
	sphere->setCenter(Vector3(0,0,0));
	sphere->setRadius(0.25);
	sphere->setMaterial(lambert);
	//g_scene->addObject(sphere);

	AARect *floor = new AARect(Vector3(-1,-1,-1), Vector3(1,-1,1), YAXIS, Vector3(0,1,0));
	floor->setMaterial(lambert);
	g_scene->addObject(floor);
	AARect *leftWall = new AARect(Vector3(-1,-1,-1), Vector3(-1,1,1), XAXIS, Vector3(1,0,0));
	leftWall->setMaterial(shiny);
	g_scene->addObject(leftWall);
	AARect *backWall = new AARect(Vector3(-1,-1,1), Vector3(1,1,1), ZAXIS, Vector3(0,0,-1));
	backWall->setMaterial(lambert);
	g_scene->addObject(backWall);
	AARect *rightWall = new AARect(Vector3(1,-1,-1), Vector3(1,1,1), XAXIS, Vector3(-1,0,0));
	rightWall->setMaterial(lambert);
	g_scene->addObject(rightWall);
	AARect *leftCeiling = new AARect(Vector3(-0.95,1,-1), Vector3(0,1,1), YAXIS, Vector3(0,-1,0));
	leftCeiling->setMaterial(lambert);
	g_scene->addObject(leftCeiling);
	AARect *rightCeiling = new AARect(Vector3(0.05,1,-1), Vector3(1,1,1), YAXIS, Vector3(0,-1,0));
	rightCeiling->setMaterial(lambert);
	g_scene->addObject(rightCeiling);

    // let objects do pre-calculations if needed
    g_scene->preCalc();
}

int main(int argc, char*argv[])
{
	make272Scene();

    MiroWindow miro(&argc, argv);
    miro.mainLoop();

    return 0; // never executed
}

